

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<html>
<head>
<script type="text/javascript" src="helpman_topicinit.js"></script>

<title>Generate Source Code [Enterprise Architect User Guide]</title>

<meta name="keywords" content="Enterprise Architect, Sparx Systems, UML, Code Engineering,Code Engineering Generate Source Code,Generate Source Code,Generate Source Code Overview,Source Code Generation,Source Code Generation Overview,Source Code Generation Class,Source Code Generation Interface,Class,Class Source Code Generation,Interface,Interface Source Code Generation">
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
<meta http-equiv="Content-Style-Type" content="text/css" />

<link type="text/css" href="default.css" rel="stylesheet" />
<style type="text/css">
  A, A:Visited
  {
    color: #00F;
  }

  A:Active, A:Hover
  {
    color: #F00;
  }

  OL
  {
    margin: 5px 0 5px 48px;
  }

  UL
  {
    margin-bottom: 3px;
    margin-top: 0;
  }

  #nsr
  {
    background-color: #D4DFFF;
  }

  #nsr A
  {
    text-decoration: none;
  }

  #mainbody
  {
    padding: 8px;
  }

  .p_BodyText
  {
    padding: 5px 0;
  }
</style>



<style type="text/css" media="screen">
  BODY
  {
    background-color: #FFFFFF;
  }

  #nsr
  {
    padding: 6px 6px 0 6px;
    border-bottom: none;
    vertical-align: top;
    z-index: 2;
    visibility: visible;
    left: 0;
    top: 0;
    position: absolute;
  }

  #mainbody
  {
    left: 0;
    top: 0;
    margin: 0;
    position: absolute;
    padding: 10px;
    overflow: auto;
    height: 100%;
    z-index: 1;
    background-repeat: no-repeat;
    background-position: bottom right;
    background-attachment: fixed;
  }
</style>

<style type="text/css" media="print">
  #nsr
  {
    visibility: none;
  }

  #mainbody
  {
    overflow: visible;
  }
</style>
<script type="text/javascript" language="JavaScript" src="nonscroll.js"></script>

</head>
<body scroll="no">

<div id="page">



        <div id="content">
          <div id="content-inner">
          



  
          <div id="nsr">
            <table border="0" cellspacing="0" cellpadding="4" width="100%">
              <tr valign="top">
                <td align="left">
  


                  <p class="p_Heading1"><span class="f_Heading1">Generate Source Code</span></p>



  
                </td>
                <td align="right">
                  <a href="introduction.htm" onmouseover="document.images.main.src='button_main_h.gif'" onmouseout="document.images.main.src='button_main.gif'">
                    <img name="main" src="button_main.gif" border=0 alt="Return to Introduction">
                  </a>&nbsp;
    
                  <a href="cgo_synchcode.htm" onmouseover="document.images.prev.src='button_prev_h.gif'" onmouseout="document.images.prev.src='button_prev.gif'">
                    <img name=prev src="button_prev.gif" border=0 alt="Previous page" />
                  </a>&nbsp;
    
    
    
                  <a href="generateasingleclass.htm" onmouseover="document.images.next.src='button_next_h.gif'" onmouseout="document.images.next.src='button_next.gif'">
                    <img name=next src="button_next.gif" border=0 alt="Next page" />
                  </a>
    
    
                </td>
              </tr>
            </table>
          </div>
          <div id="mainbody">
  


                <p class="p_TextIndentedL1"><img src="generate_source_code.png" width="425" height="100" border="0" alt="generate_source_code"></p>
<p class="p_BodyText"><span class="f_BodyText">Generating source code (forward engineering) takes the UML Class or Interface model elements and creates a source code equivalent for future elaboration and compilation. By forward engineering code from the model, the mundane work involved with having to key in Classes and attributes and methods is avoided, and symmetry between model and code is ensured.</span></p>
<p class="p_BodyText"><span class="f_BodyText">Code is generated from </span><span class="f_BodyText" style="font-style: italic;">Class</span><span class="f_BodyText"> or</span><span class="f_BodyText"> </span><span class="f_BodyText" style="font-style: italic;">Interface</span><span class="f_BodyText"> model elements, so you must create the required Class and Interface elements to generate from. Add attributes (which become variables) and operations (which become methods).</span></p>
<p class="p_BodyText"><span class="f_BodyText">Before you generate code, you should ensure the default settings for code generation match your requirements. The default generation settings are located in the </span><span class="f_UIControl">Source Code Engineering</span><span class="f_BodyText"> page of the </span><span class="f_UIControl">Options</span><span class="f_BodyText"> dialog (select the </span><span class="f_MenuKeyField">Tools | Options | Source Code Engineering</span><span class="f_BodyText"> menu option). Set up the defaults to match your required language and preferences. Preferences that you can define include default constructors and destructors, methods for interfaces and the Unicode options for created languages. Languages such as Java support <a href="namespaces.htm">namespaces</a> and can be configured to specify a namespace root. In addition to the default settings for generating code, Enterprise Architect supports the following code languages with their own specific code generation options:</span></p>
<ul style="text-indent: 0px; margin-left: 30px; list-style-position: outside;">
<li><span class="f_Bulletlist1"><a href="options___actionscript.htm">ActionScript</a></span></li>
<li><span class="f_Bulletlist1"><a href="options___c.htm">C</a></span></li>
<li><span class="f_Bulletlist1"><a href="cgo_cs.htm">C#</a> (for both .NET 1.1 and .NET 2.0)</span></li>
<li><span class="f_Bulletlist1"><a href="cgo_cpp.htm">C++</a> (standard, plus .NET managed C++ extensions)</span></li>
<li><span class="f_Bulletlist1"><a href="cgo_delphi.htm">Delphi</a></span></li>
<li><span class="f_Bulletlist1"><a href="cgo_java.htm">Java</a> (including Java 1.5, Aspects and Generics)</span></li>
<li><span class="f_Bulletlist1"><a href="options_php.htm">PHP</a></span></li>
<li><span class="f_Bulletlist1"><a href="options___python.htm">Python</a></span></li>
<li><span class="f_Bulletlist1"><a href="cgo_vb.htm">Visual Basic</a></span></li>
<li><span class="f_Bulletlist1"><a href="cgo_vbnet.htm">Visual Basic .NET</a></span></li>
</ul>
<p class="p_BodyText"><span class="f_BodyText">The <a href="codetemplates.htm">Code Template Framework (CTF)</a> enables you to customize the way Enterprise Architect generates source code and also enables generation of languages that are not specifically supported by Enterprise Architect.</span></p>
<p class="p_BodyText"><span class="f_BodyText">Before generating code, you should also familiarize yourself with the way Enterprise Architect handles local path names. Local path names enable you to substitute tags for directory names (e.g. </span><span class="f_Code">%SRC% = C:\Source</span><span class="f_BodyText">).</span></p>
<p class="p_BodyText"><span class="f_BodyText">When you have completed the design of your Classes, you can generate source code.</span></p>
<div style="text-align: left; text-indent: 0px; padding: 0px 0px 0px 0px; margin: 5px 0px 5px 13px;"><table cellspacing="0" cellpadding="2" border="0" style="border: none; border-spacing:0px;">
<tr style="text-align:left;vertical-align:bottom;">
<td valign="bottom" width="952" bgcolor="#efeff7" style="width:952px; background-color:#efeff7;"><p class="p_TiporNote" style="border-top: none; border-right: none; border-left: none;"><span class="f_TiporNote">Note:</span></p>
</td>
</tr>
<tr style="text-align:left;">
<td width="952" bgcolor="#f7f7ff" style="width:952px; background-color:#f7f7ff;"><p class="p_TiporNoteText"><span class="f_TiporNoteText">In the </span><span class="f_TiporNoteText">Corporate, Business and Software Engineering, System Engineering and Ultimate editions</span><span class="f_TiporNoteText"> of Enterprise Architect, if security is enabled you must have </span><span class="f_TiporNoteText" style="font-weight: bold;"><a href="permissionlist.htm">Generate Source Code and DDL</a></span><span class="f_TiporNoteText"> permission to generate source code.</span></p>
</td>
</tr>
</table>
</div>
<p class="p_SubHeadingL1"><span class="f_SubHeadingL1">Use Live Code Generation</span></p>
<p class="p_BodyText"><span class="f_BodyText">On the </span><span class="f_UIControl"><a href="sourcecodeconfiguration.htm">Package Build Scripts</a></span><span class="f_BodyText"> dialog, you have the option to </span><span class="f_BodyText">update your source code instantly as you make changes to your model.</span></p>
<p class="p_SubHeadingL1"><span class="f_SubHeadingL1">Tasks</span></p>
<p class="p_BodyText"><span class="f_BodyText">When you generate code, you perform one or more of the following tasks:</span></p>
<ul style="text-indent: 0px; margin-left: 30px; list-style-position: outside;">
<li><span class="f_Bulletlist1"><a href="generateasingleclass.htm">Generate a Single Class</a></span></li>
<li><span class="f_Bulletlist1"><a href="generateagroupofclasses.htm">Generate a Group of Classes</a></span></li>
<li><span class="f_Bulletlist1"><a href="generateapackage.htm">Generate a Package</a></span></li>
<li><span class="f_Bulletlist1"><a href="synchronizepackagetree.htm">Update Package Contents</a></span></li>
</ul>




            </div>
          </div>
        </div>



</div>


</body>
</html>
